import 'package:flutter/material.dart';
import 'package:wuliu01/TopTab/Completed.dart';
import 'package:wuliu01/TopTab/OntheWay.dart';
import 'package:wuliu01/TopTab/WaittingGoods.dart';

class TopTabBarPage extends StatefulWidget {
  const TopTabBarPage({super.key});

  @override
  State<TopTabBarPage> createState() => _TopTabBarPageState();
}

class _TopTabBarPageState extends State<TopTabBarPage>
    with SingleTickerProviderStateMixin {
  late TabController _tabController;
  final List<Widget> tabContents = [
    Waittinggoods(), // 保持原有页面组件
    Ontheway(),
    Completed(),
  ];

  @override
  void initState() {
    super.initState();
    _tabController = TabController(length: 3, vsync: this);
  }

  @override
  void dispose() {
    _tabController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        bottom: TabBar(
          controller: _tabController,
          tabs: const [Tab(text: '待提货'), Tab(text: '在途'), Tab(text: '已完成')],
          isScrollable: true,
          indicatorColor: Colors.red,
          labelColor: Colors.black,
        ),
      ),
      body: TabBarView(controller: _tabController, children: tabContents),
    );
  }
}
